﻿using System;
using System.Linq;

namespace PayrollSystemLibrary.Model
{
    public class DataAccessHelper :IDisposable
    {
        private readonly PayrollReduxEntities _context;

        public DataAccessHelper()
        {
                _context= new PayrollReduxEntities();
        }
        public void Add(Employee employee)
        {
            _context.AddToEmployees(employee);
        }
        public Employee FindByEmployeeId(decimal empId)
        {
           var employee = (from e in _context.Employees where e.EmpId == 1 select e).SingleOrDefault();
            return employee;
        }
        public void Save()
        {
            _context.SaveChanges();
        }
        public void Dispose()
        {
            if (_context!=null) _context.Dispose();
        }
    }
}
